package mortal.game.resource
{
	import com.gengine.resource.*;
	import flash.utils.*;
	import mortal.game.resource.info.*;
	
	public class SWFModelConfig extends Object
	{
		private var _map:Dictionary;
		private var _codeMap:Dictionary;
		private static var _instance:SWFModelConfig;
		
		public function SWFModelConfig()
		{
			this._map = new Dictionary();
			this._codeMap = new Dictionary();
			if (_instance != null)
			{
				throw new Error(" ResConfig 单例 ");
			}
			
		}
		
		private function write(file:Object) : void
		{
			var info:SWFModelInfo = null;
			var item:Object = null;
			var obj:Object = null;
			for each (item in file.modles)
			{
				
				this._codeMap[item.code] = item.isDiffCareer;
				for each (obj in item.modle)
				{
					
					info = new SWFModelInfo();
					info.career = obj.career;
					info.code = item.code;
					info.sex = obj.sex;
					info.attackAction = obj.attackAction;
					info.mountAction = obj.mountAction;
					info.modle = obj.modle;
					info.stallAction = obj.stallAction;
					this._map[info.code + "" + info.career + info.sex] = info;
				}
			}
			
		}
		
		public function init() : void
		{
			var file:Object = ConfigManager.instance.getObjectByFileName("swfModle.xml");
			write(file);
			
		}
		
		public function getInfoByCode(param1:Object, param2:int, param3:int) : String
		{
			if (this._codeMap[param1])
			{
				return param1 + "" + param3 + param2;
			}
			return param1 + "0" + param2;
		}
		
		public function getModelInfo(key:Object) : SWFModelInfo
		{
			return this._map[key];
		}
		
		public static function get instance() : SWFModelConfig
		{
			if (_instance == null)
			{
				_instance = new SWFModelConfig;
			}
			return _instance;
		}
		
	}
}
